package admin

import database "hft/Database"

type Region struct {
	database.Base
	PID            uint          `json:"pid,omitempty" gorm:"foreignKey:PID;references:ID;constraint:OnDelete:CASCADE,OnUpdate:NO ACTION"`
	Name           string        `json:"name,omitempty"`
	Alias          string        `json:"alias" gorm:"comment:别名"`
	Center         string        `json:"center,omitempty"`
	Longitude      float64       `json:"longitude,omitempty"`
	Latitude       float64       `json:"latitude,omitempty"`
	FirstWord      string        `json:"firstWord" gorm:"comment:首字母"`
	Level          string        `json:"level,omitempty"`
	Link           string        `json:"link,omitempty" gorm:"type:varchar(255);size:255;index"`
	CanAddChild    bool          `json:"canAddChild,omitempty"`
	IsHot          bool          `json:"isHot" gorm:"comment:是否是热门城市"`
	ManageId       uint          `json:"manageId,omitempty" gorm:"index;type:int;size:255"`
	OverTime       int           `json:"over_time"` //过期时间
	PreFix         string        `json:"prefix" gorm:"comment:站点前缀"`
	IsDefault      bool          `json:"isDefault" gorm:"comment:是否为默认城市;default:0"`
	IsCityProvince bool          `json:"isCityProvince" comment:"是否为地级市"`
	Districts      []*Region     `json:"districts,omitempty" gorm:"foreignKey:PID"`
	LouNameList    []*LouPanName `json:"louNameList" gorm:"foreignKey:RegionId;references:ID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
}

func (Region) TableName() string {
	return database.TableNameFormat("regions")
}
